package com.cupcorn.balapkarung.entity;

import com.cupcorn.lib.game.GameAnimatedSprite;

public class MC
{
	public final int			IDLE	= 0, MOVE = 1, JUMP = 2, DIE = 3;
	public int					curState;
	
	public final int					SPEED	= 60, X_JUMP_SPEED = 0, Y_JUMP_SPEED = 300, GRAVITATION = 0;
	int							ySpeed;
	boolean isJumpDown;
	
	public GameAnimatedSprite	mc;
	
	public MC(GameAnimatedSprite mc)
	{
		this.mc = mc;

		isJumpDown = true;
	}
	
	public void switchState(int state)
	{
		curState = state;
		
		switch (state)
		{
			case IDLE:
				idle();
				break;
			case MOVE:
				move();
				break;
			case JUMP:
				jump();
				break;
			case DIE:
				die();
				break;
		}
	}
	
	public void onUpdate(float deltaTime)
	{
		switch (curState)
		{
			case IDLE:
				idleUpdate(deltaTime);
				break;
			case MOVE:
				moveUpdate(deltaTime);
				break;
			case JUMP:
				jumpUpdate(deltaTime);
				break;
			case DIE:
				dieUpdate(deltaTime);
				break;
		}
	}
	
	private void idle()
	{	
		
	}
	
	private void idleUpdate(float deltaTime)
	{	
		
	}
	
	private void move()
	{	
		
	}
	
	private void moveUpdate(float deltaTime)
	{
		mc.setPosition(mc.getX() + SPEED * deltaTime, mc.getY());
	}
	
	private void jump()
	{
		// ySpeed = -Y_JUMP_SPEED;
		isJumpDown = false;
//		mc.setPosition(mc.getX(), mc.getY() - 2);
	}
	
	private void jumpUpdate(float deltaTime)
	{
		// ySpeed = ySpeed + GRAVITATION;
		mc.setPosition(mc.getX() + SPEED * deltaTime + X_JUMP_SPEED * deltaTime, mc.getY() - Y_JUMP_SPEED * deltaTime);
	}
	
	private void die()
	{	
		
	}
	
	private void dieUpdate(float deltaTime)
	{	
		
	}
}
